package cmsapi

import (
	"oxy_server/res/cmsserver/approval"
	"oxy_server/res/cmsserver/designplan"
	"oxy_server/res/cmsserver/designpostproduct"
	"oxy_server/res/cmsserver/homestatistics"
	"oxy_server/res/cmsserver/issues"
	"oxy_server/res/cmsserver/logger"
	"oxy_server/res/cmsserver/operationplan"
	"oxy_server/res/cmsserver/orderplan"
	"oxy_server/res/cmsserver/pay"
	"oxy_server/res/cmsserver/paymentplan"
	"oxy_server/res/cmsserver/productplan"
	"oxy_server/res/cmsserver/productproperty"
	"oxy_server/res/cmsserver/purchases"
	"oxy_server/res/cmsserver/returngoods"
	"oxy_server/res/cmsserver/salesdata"
	"oxy_server/res/cmsserver/skuorder"
	"oxy_server/router/dicapi"

	"github.com/labstack/echo"
)

//-----
// API Routers
//-----
func Routers(e *echo.Echo) *echo.Echo {
	e.Logger.SetPrefix("api")
	salesdata := salesdata.NewSalesData()
	returngoods := returngoods.NewReturnData()
	operationplan := operationplan.NewOperationPlanData()
	paymentplan := paymentplan.NewPaymentPlanData()
	designplan := designplan.NewDesignPlanData()
	pproperty := productproperty.New("")
	dproperty := productproperty.New("design")
	productplanorder := productplan.New("new")
	productplan := productplan.New("old")
	home := homestatistics.New()
	iss := issues.New()
	purchasespkg := purchases.New()
	ordermode := orderplan.New()

	approvalpac := approval.New()
	skuorderv1 := skuorder.New("v1")
	skuorderv2 := skuorder.New("v2")
	skuorderv3 := skuorder.New("v3")
	payv1 := pay.New("v1")
	payv2 := pay.New("v2")
	loggerv1 := logger.New("v1")
	// Routers
	api := e.Group("/api")
	desProRel := designpostproduct.New()
	api.Use(dicapi.CheckSession)
	{
		// upload
		api.POST("/upload", Upload)
		api.DELETE("/delfile", DelFile)

		// product
		api.GET("/product/list", GetProductListHandler)
		api.POST("/product/add", AddProductHandler)
		api.POST("/product/update", UpdateProductHandler)
		api.GET("/product", GetProductInfoHandler)
		api.DELETE("/product", DelProductHandler)

		// productissues
		api.GET("/productissues/list", GetProductIssuesListHandler)
		api.POST("/productissues/add", AddProductIssuesHandler)
		api.POST("/productissues/update", UpdateProductIssuesHandler)
		api.DELETE("/productissues", DelProductIssuesHandler)
		api.GET("/productissues", GetProductIssuesInfoHandler)

		// productiongroup
		api.GET("/productiongroup/list", GetProductionGroupListHandler)
		api.POST("/productiongroup/add", AddProductionGroupHandler)
		api.POST("/productiongroup/update", UpdateProductionGroupHandler)
		api.DELETE("/productiongroup", DelProductionGroupHandler)

		// designgroup
		api.GET("/designgroup/list", GetDesignGroupListHandler)
		api.POST("/designgroup/add", AddDesignGroupHandler)
		api.POST("/designgroup/update", UpdateDesignGroupHandler)
		api.DELETE("/designgroup", DelDesignGroupHandler)

		// editorgroup
		api.GET("/editorgroup/list", GetEditorGroupListHandler)
		api.POST("/editorgroup/add", AddEditorGroupHandler)
		api.POST("/editorgroup/update", UpdateEditorGroupHandler)
		api.DELETE("/editorgroup", DelEditorGroupHandler)

		// operationgroup
		api.GET("/operationgroup/list", GetOperationGroupListHandler)
		api.POST("/operationgroup/add", AddOperationGroupHandler)
		api.POST("/operationgroup/update", UpdateOperationGroupHandler)
		api.DELETE("/operationgroup", DelOperationGroupHandler)

		// photographygroup
		api.GET("/photographygroup/list", GetPhotographyGroupListHandler)
		api.POST("/photographygroup/add", AddPhotographyGroupHandler)
		api.POST("/photographygroup/update", UpdatePhotographyGroupHandler)
		api.DELETE("/photographygroup", DelPhotographyGroupHandler)

		// facegroup
		api.GET("/facegroup/list", GetFaceGroupListHandler)
		api.POST("/facegroup/add", AddFaceGroupHandler)
		api.POST("/facegroup/update", UpdateFaceGroupHandler)
		api.DELETE("/facegroup", DelFaceGroupHandler)

		// sku
		api.GET("/sku/list", GetSkuListHandler)
		api.GET("/sku/analyse", GetSkuListAnalyseHandler)
		api.POST("/sku/add", AddSkuHandler)
		api.POST("/sku/adds", AddSkusHandler)
		api.POST("/sku/update", UpdateSkuHandler)
		api.POST("/sku/updates", UpdateSkusHandler)
		api.DELETE("/sku", DelSkuHandler)

		// tagprice
		api.GET("/tagprice/list", GetTagPriceListHandler)
		api.POST("/tagprice/add", AddTagPriceHandler)
		api.POST("/tagprice/update", UpdateTagPriceHandler)
		api.DELETE("/tagprice", DelTagPriceHandler)

		// samplepackage
		// api.GET("/samplepackage/list", GetSamplePackageListHandler)
		// api.POST("/samplepackage/add", AddSamplePackageHandler)
		// api.POST("/samplepackage/update", UpdateSamplePackageHandler)
		// api.DELETE("/samplepackage", DelSamplePackageHandler)

		// certificatetemplatewatermarktemplate
		api.GET("/certificatetemplate/list", GetCertificateTemplateListHandler)
		api.POST("/certificatetemplate/add", AddCertificateTemplateHandler)
		api.POST("/certificatetemplate/update", UpdateCertificateTemplateHandler)
		api.DELETE("/certificatetemplate", DelCertificateTemplateHandler)

		// watermarktemplate
		api.GET("/watermarktemplate/list", GetWaterMarkTemplateListHandler)
		api.POST("/watermarktemplate/add", AddWaterMarkTemplateHandler)
		api.POST("/watermarktemplate/update", UpdateWaterMarkTemplateHandler)
		api.DELETE("/watermarktemplate", DelWaterMarkTemplateHandler)

		// bom
		api.GET("/bom/list", GetBomListHandler)
		api.POST("/bom/add", AddBomHandler)
		api.POST("/bom/update", UpdateBomHandler)
		api.GET("/bom", GetBomInfoHandler)
		api.DELETE("/bom", DelBomHandler)

		// accounting
		api.GET("/accounting/list", payv1.GetListHandler)
		api.POST("/accounting/add", payv1.AddHandler)
		api.POST("/accounting/update", payv1.UpdateHandler)
		api.DELETE("/accounting", payv1.DelHandler)
		// pay
		api.GET("/pay/list", payv2.GetListHandler)
		api.POST("/pay/add", payv2.AddHandler)
		api.POST("/pay/update", payv2.UpdateHandler)
		api.DELETE("/pay", payv2.DelHandler)

		// skuorder
		api.GET("/skuorder/list", skuorderv1.GetSkuOrderListHandler)
		api.POST("/skuorder/add", skuorderv1.AddSkuOrderHandler)
		api.POST("/skuorder/update", skuorderv1.UpdateSkuOrderHandler)
		api.DELETE("/skuorder", skuorderv1.DelSkuOrderHandler)

		api.POST("/skuorder/newadd", skuorderv2.AddSkuOrderHandler)
		api.POST("/skuorder/newupdate", skuorderv2.UpdateSkuOrderHandler)
		api.DELETE("/skuordernew", skuorderv2.DelSkuOrderHandler)

		api.GET("/v3/skuorder/list", skuorderv3.GetSkuOrderListHandler)
		api.POST("/v3/skuorder/add", skuorderv3.AddSkuOrderHandler)
		api.POST("/v3/skuorder/update", skuorderv3.UpdateSkuOrderHandler)
		api.DELETE("/skuorder/v3", skuorderv3.DelSkuOrderHandler)

		// salesdata

		api.GET("/sales/list", salesdata.GetSalesDataListHandler)
		api.GET("/sales/largenumber", salesdata.GetSalesLargeNumberListHandler)
		api.GET("/sales/sku", salesdata.GetSalesSkuListHandler)
		api.POST("/sales/add", salesdata.AddSalesDataHandler)
		api.POST("/combine/sales/add", salesdata.AddCombineSalesDataHandler)
		api.GET("/combine/sales/list", salesdata.GetCombineSalesDataListHandler)
		api.DELETE("/combine/sales", salesdata.DelCombineSalesData)

		// return goods
		api.GET("/return/list", returngoods.GetReturnDataListHandler)
		api.POST("/return/add", returngoods.AddReturnDataHandler)
		api.GET("/return/largenumber", returngoods.GetReturnLargeNumberListHandler)
		api.GET("/return/sku", returngoods.GetReturnSkuListHandler)

		// operationplan
		api.GET("/operationplan/list", operationplan.GetOperationPlanListHandler)
		api.GET("/operationplan", operationplan.GetOperationPlanInfoHandler)
		api.POST("/operationplan/add", operationplan.AddOperationPlanHandler)
		api.POST("/operationplan/update", operationplan.UpdateOperationPlanHandler)
		api.DELETE("/operationplan", operationplan.DelOperationPlanHandler)

		// paymentplan
		api.GET("/paymentplan/list", paymentplan.GetPaymentPlanListHandler)
		api.POST("/paymentplan/add", paymentplan.AddPaymentPlanHandler)
		api.POST("/paymentplan/update", paymentplan.UpdatePaymentPlanHandler)
		api.DELETE("/paymentplan", paymentplan.DelPaymentPlanHandler)

		// designplan
		api.GET("/designplan/list", designplan.GetDesignPlanListHandler)
		api.GET("/designplan", designplan.GetDesignPlanInfoHandler)
		api.POST("/designplan/add", designplan.AddDesignPlanHandler)
		api.POST("/designplan/import", designplan.AddDesignsPlanHandler)
		api.POST("/designplan/update", designplan.UpdateDesignPlanHandler)
		api.POST("/designplan/order/update", designplan.UpdateDesignPlanOrderHandler)
		api.POST("/designplan/tabs", designplan.UpdateProductTabsHandler)
		api.DELETE("/designplan", designplan.DelDesignPlanHandler)

		// productnplan productproperty
		api.GET("/productproperty/list", pproperty.GetProductPropertyListHandler)
		api.POST("/productproperty/add", pproperty.AddProductPropertyHandler)
		api.POST("/productproperty/update", pproperty.UpdateProductPropertyHandler)
		api.DELETE("/productproperty", pproperty.DelProductPropertyHandler)

		// designplan productproperty
		api.GET("/designproperty/list", dproperty.GetProductPropertyListHandler)
		api.POST("/designproperty/add", dproperty.AddProductPropertyHandler)
		api.POST("/designproperty/update", dproperty.UpdateProductPropertyHandler)
		api.DELETE("/designproperty", dproperty.DelProductPropertyHandler)

		// productplan
		api.GET("/productplan/list", productplan.GetProductPlanListHandler)
		api.GET("/productplan", productplan.GetProductPlanInfoHandler)
		api.POST("/productplan/add", productplan.AddProductPlanHandler)
		api.POST("/productplan/update", productplan.UpdateProductPlanHandler)
		api.DELETE("/productplan", productplan.DelProductPlanHandler)
		api.POST("/productplan/all", productplan.DelProductPlanListHandler)

		// productplanorder
		api.GET("/productplanorder/list", productplanorder.GetProductPlanListHandler)
		api.GET("/productplanorder", productplanorder.GetProductPlanInfoHandler)
		api.POST("/productplanorder/add", productplanorder.AddProductPlanHandler)
		api.POST("/productplanorder/update", productplanorder.UpdateProductPlanHandler)
		api.DELETE("/productplanorder", productplanorder.DelProductPlanHandler)
		api.POST("/productplanorder/all", productplanorder.DelProductPlanListHandler)

		// homestatistics
		api.GET("/home/list", home.GetOperationPlanListHandler)
		api.GET("/home/list/details", home.GetDesignPlanListHandler)

		// issues
		api.GET("/issues/list", iss.GetIssuesListHandler)
		api.POST("/issues/add", iss.AddIssuesHandler)
		api.POST("/issues/update", iss.UpdateIssuesHandler)
		api.DELETE("/issues", iss.DelIssuesHandler)
		api.GET("/issues", iss.GetIssuesInfoHandler)

		// design product res
		api.POST("/design_product/add", desProRel.AddHandler)
		api.POST("/design_product/update", desProRel.UpdateHandler)
		api.GET("/design_product", desProRel.GetInfoHandler)

		// approval
		api.GET("/approval/list", approvalpac.GetListHandler)
		api.POST("/approval/add", approvalpac.AddHandler)
		api.POST("/approval/update", approvalpac.UpdateHandler)
		api.DELETE("/approval", approvalpac.DelHandler)
		api.GET("/approval", approvalpac.GetInfoHandler)

		// order mode
		api.POST("/ordermode/add", ordermode.AddOrderModeHandler)
		api.GET("/ordermode/list", ordermode.GetOrderModeListHandler)
		api.GET("/ordermode", ordermode.GetOrderModeInfoHandler)
		api.DELETE("/ordermode", ordermode.DelOrderModeHandler)
		api.POST("/ordermode/update", ordermode.UpdateOrderModeHandler)
		api.POST("/ordermode/update/design", ordermode.DesignUpdateProductHandler)
		api.POST("/ordermode/update/quality", ordermode.QualityUpdateProductHandler)
		api.POST("/ordermode/update/opinion", ordermode.QualityUpdateProductOpinionHandler)
		api.GET("/ordermode/update/purchases", ordermode.PurchasesUpdateStatusHandler)

		api.POST("/ordermode/update/editer", ordermode.DesignUpdateEditerHandler)
		api.POST("/ordermode/update/product", ordermode.ProductUpdateBaseHandler)

		// purchases
		api.GET("/ordermaterial/list", purchasespkg.GetMaterialListHandler)
		api.GET("/ordermaterial/money", purchasespkg.GeStatisticsHandler)

		api.GET("/purchases/list", purchasespkg.GetListHandler)
		api.POST("/purchases/add", purchasespkg.AddHandler)
		api.POST("/purchases/update", purchasespkg.UpdateHandler)
		api.DELETE("/purchases", purchasespkg.DelHandler)
		api.GET("/purchases", purchasespkg.GetInfoHandler)

		// 更新生产组大货号
		api.POST("/productlargenumber", productplan.UpdateProductLargeNumber)
		// 更新设计组大货号
		api.POST("/designorderlargenumber", productplan.UpdateDesignPlanListOrderInfoHandler)
		// 更新sku 列表
		api.POST("/updatesku", UpdateSkuCode)
		// 更新订单sku 信息
		api.POST("/updateskuorderinfo", skuorderv2.UpdateSkuOrderInfo)

		api.GET("/log/list", loggerv1.GetListHandler)
		api.DELETE("/log", loggerv1.DelHandler)

	}
	return e
}
